﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using System.Windows;
using System.Windows.Input;

using HA.Data;

using HA.ModFlow.Controls.Windows;

using HA.ModFlow.Controls.Windows.MapData;

using HA.ModFlow.Domain.DomainLayer;

using HA.ModFlow.Infrastructure;

using HA.ModFlow.Controls;



namespace HA.ModFlow.Application
{

    /// <summary>
    /// 设计用于modflow二次改进时，增加 的命令模型
    /// </summary>
   public static class ModflowV2Commands
    {

       static ModflowV2Commands()
       {

           editHK = new RoutedCommand();
 
       }


       //流动系统部分

       static RoutedCommand editHK;

       public static RoutedCommand EditHK
       {
           get { return ModflowV2Commands.editHK; }
          
       }
       public static Window mainWindow;
       static RoutedCommand editHani = new RoutedCommand();

       public static RoutedCommand EditHani
       {
           get { return ModflowV2Commands.editHani; }        
       }

       static RoutedCommand editSs = new RoutedCommand();

       public static RoutedCommand EditSs
       {
           get { return ModflowV2Commands.editSs; }         
       }

       static RoutedCommand editSy = new RoutedCommand();

       public static RoutedCommand EditSy
       {
           get { return ModflowV2Commands.editSy; }         
       }

       static RoutedCommand editVka = new RoutedCommand();

       public static RoutedCommand EditVka
       {
           get { return ModflowV2Commands.editVka; }        
       }

       static RoutedCommand editVkcb = new RoutedCommand();

       public static RoutedCommand EditVkcb
       {
           get { return ModflowV2Commands.editVkcb; }        
       }

       static RoutedCommand editTransmissivity = new RoutedCommand();

       public static RoutedCommand EditTransmissivity
       {
           get { return ModflowV2Commands.editTransmissivity; }          
       }

       static RoutedCommand editPrimaryStorage = new RoutedCommand();

       public static RoutedCommand EditPrimaryStorage
       {
           get { return ModflowV2Commands.editPrimaryStorage; }          
       }

       static RoutedCommand editSecondaryStorage = new RoutedCommand();

       public static RoutedCommand EditSecondaryStorage
       {
           get { return ModflowV2Commands.editSecondaryStorage; }          
       }

       static RoutedCommand editLeakance = new RoutedCommand();

       public static RoutedCommand EditLeakance
       {
           get { return ModflowV2Commands.editLeakance; }        
       }

       static RoutedCommand editWetDry = new RoutedCommand();

       public static RoutedCommand EditWetDry
       {
           get { return ModflowV2Commands.editWetDry; }          
       }

       static RoutedCommand editHead = new RoutedCommand();

       public static RoutedCommand EditHead
       {
           get { return ModflowV2Commands.editHead; }         
       }
       static RoutedCommand editIbound = new RoutedCommand();

       public static RoutedCommand EditIbound
       {
           get { return ModflowV2Commands.editIbound; }
         
       }
       static RoutedCommand editTopElevation = new RoutedCommand();

       public static RoutedCommand EditTopElevation
       {
           get { return ModflowV2Commands.editTopElevation; }
           set { ModflowV2Commands.editTopElevation = value; }
       }
       static RoutedCommand editBootElevation = new RoutedCommand();

       public static RoutedCommand EditBootElevation
       {
           get { return ModflowV2Commands.editBootElevation; }         
       }

       static RoutedCommand scatter2dTool = new RoutedCommand();

       public static RoutedCommand Scatter2dTool
       {
           get { return ModflowV2Commands.scatter2dTool; }
          
       }

       static RoutedCommand grid3dTool = new RoutedCommand();

       public static RoutedCommand Grid3dTool
       {
           get { return ModflowV2Commands.grid3dTool; }
          
       }

       static RoutedCommand mapDataTool = new RoutedCommand();

       public static RoutedCommand MapDataTool
       {
           get { return ModflowV2Commands.mapDataTool; } 
           
          
       }

       static RoutedCommand view2d3d = new RoutedCommand();

       public static RoutedCommand View2d3d
       {
           get { return ModflowV2Commands.view2d3d; }
         
       }




       public static void BindCommandsToWindow(Window window)
       {
           CommandBinding cbEditHk = new CommandBinding();
           cbEditHk.Command = editHK;
           cbEditHk.CanExecute += new CanExecuteRoutedEventHandler(cbEditHk_CanExecute);
           cbEditHk.Executed += new ExecutedRoutedEventHandler(cbEditHk_Executed);
           window.CommandBindings.Add(cbEditHk);

           CommandBinding cbEditHani = new CommandBinding();
           cbEditHani.Command = editHani;
           cbEditHani.Executed += new ExecutedRoutedEventHandler(cbEditHani_Executed);
           cbEditHani.CanExecute += new CanExecuteRoutedEventHandler(cbEditHani_CanExecute);
           window.CommandBindings.Add(cbEditHani);

           CommandBinding cbEditSs = new CommandBinding();
           cbEditSs.Command = editSs;
           cbEditSs.Executed += new ExecutedRoutedEventHandler(cbEditSs_Executed);
           cbEditSs.CanExecute += new CanExecuteRoutedEventHandler(cbEditSs_CanExecute);
           window.CommandBindings.Add(cbEditSs);

           CommandBinding cbEditSy = new CommandBinding();
           cbEditSy.Command = editSy;
           cbEditSy.CanExecute += new CanExecuteRoutedEventHandler(cbEditSy_CanExecute);
           cbEditSy.Executed += new ExecutedRoutedEventHandler(cbEditSy_Executed);
           window.CommandBindings.Add(cbEditSy);

           CommandBinding cbEditVka = new CommandBinding();
           cbEditVka.Command = editVka;
           cbEditVka.CanExecute += new CanExecuteRoutedEventHandler(cbEditVka_CanExecute);
           cbEditVka.Executed += new ExecutedRoutedEventHandler(cbEditVka_Executed);
           window.CommandBindings.Add(cbEditVka);

           CommandBinding cbEditVkcb = new CommandBinding();
           cbEditVkcb.Command = editVkcb;
           cbEditVkcb.CanExecute += new CanExecuteRoutedEventHandler(cbEditVkcb_CanExecute);
           cbEditVkcb.Executed += new ExecutedRoutedEventHandler(cbEditVkcb_Executed);
           window.CommandBindings.Add(cbEditVkcb);

           CommandBinding cbEditTransmissivity = new CommandBinding();
           cbEditTransmissivity.Command = editTransmissivity;
           cbEditTransmissivity.CanExecute += new CanExecuteRoutedEventHandler(cbEditTransmissivity_CanExecute);
           cbEditTransmissivity.Executed += new ExecutedRoutedEventHandler(cbEditTransmissivity_Executed);
           window.CommandBindings.Add(cbEditTransmissivity);

           CommandBinding cbEditPrimaryStorage = new CommandBinding();
           cbEditPrimaryStorage.Command = editPrimaryStorage;
           cbEditPrimaryStorage.CanExecute += new CanExecuteRoutedEventHandler(cbEditPrimaryStorage_CanExecute);
           cbEditPrimaryStorage.Executed += new ExecutedRoutedEventHandler(cbEditPrimaryStorage_Executed);
           window.CommandBindings.Add(cbEditPrimaryStorage);

           CommandBinding cbEditSecondaryStorage = new CommandBinding();
           cbEditSecondaryStorage.Command = editSecondaryStorage;
           cbEditSecondaryStorage.CanExecute += new CanExecuteRoutedEventHandler(cbEditSecondaryStorage_CanExecute);
           cbEditSecondaryStorage.Executed += new ExecutedRoutedEventHandler(cbEditSecondaryStorage_Executed);
           window.CommandBindings.Add(cbEditSecondaryStorage);

           CommandBinding cbEditLeakance = new CommandBinding();
           cbEditLeakance.Command = editLeakance;
           cbEditLeakance.CanExecute += new CanExecuteRoutedEventHandler(cbEditLeakance_CanExecute);
           cbEditLeakance.Executed += new ExecutedRoutedEventHandler(cbEditLeakance_Executed);
           window.CommandBindings.Add(cbEditLeakance);

           CommandBinding cbEditWetDry = new CommandBinding();
           cbEditWetDry.Command = editWetDry;
           cbEditWetDry.Executed += new ExecutedRoutedEventHandler(cbEditWetDry_Executed);
           cbEditWetDry.CanExecute += new CanExecuteRoutedEventHandler(cbEditWetDry_CanExecute);
           window.CommandBindings.Add(cbEditWetDry);

           CommandBinding cbEditHead = new CommandBinding();
           cbEditHead.Command = editHead;
           cbEditHead.Executed += new ExecutedRoutedEventHandler(cbEditHead_Executed);
           cbEditHead.CanExecute += new CanExecuteRoutedEventHandler(cbEditHead_CanExecute);
           window.CommandBindings.Add(cbEditHead);

           CommandBinding cbEditIbound = new CommandBinding();
           cbEditIbound.Command = editIbound;
           cbEditIbound.CanExecute += new CanExecuteRoutedEventHandler(cbEditIbound_CanExecute);
           cbEditIbound.Executed += new ExecutedRoutedEventHandler(cbEditIbound_Executed);
           window.CommandBindings.Add(cbEditIbound);

           CommandBinding cbEditTopElevation = new CommandBinding();
           cbEditTopElevation.Command = editTopElevation;
           cbEditTopElevation.Executed += new ExecutedRoutedEventHandler(cbEditTopElevation_Executed);
           cbEditTopElevation.CanExecute += new CanExecuteRoutedEventHandler(cbEditTopElevation_CanExecute);
           window.CommandBindings.Add(cbEditTopElevation);

           CommandBinding cbEditBootElevation = new CommandBinding();
           cbEditBootElevation.Command = editBootElevation;
           cbEditBootElevation.Executed += new ExecutedRoutedEventHandler(cbEditBootElevation_Executed);
           cbEditBootElevation.CanExecute += new CanExecuteRoutedEventHandler(cbEditBootElevation_CanExecute);
           window.CommandBindings.Add(cbEditBootElevation);




           CommandBinding cbScatter2dTool = new CommandBinding();
           cbScatter2dTool.Command = scatter2dTool;
           cbScatter2dTool.Executed += new ExecutedRoutedEventHandler(cbScatter2dTool_Executed);
           cbScatter2dTool.CanExecute += new CanExecuteRoutedEventHandler(cbScatter2dTool_CanExecute);
           window.CommandBindings.Add(cbScatter2dTool);


           CommandBinding cbGrid3dTool = new CommandBinding();
           cbGrid3dTool.Command = grid3dTool;
           cbGrid3dTool.Executed += new ExecutedRoutedEventHandler(cbGrid3dTool_Executed);
           cbGrid3dTool.CanExecute += new CanExecuteRoutedEventHandler(cbGrid3dTool_CanExecute);
           window.CommandBindings.Add(cbGrid3dTool);

           CommandBinding cbMapDataTool = new CommandBinding();
           cbMapDataTool.Command = mapDataTool;
           cbMapDataTool.Executed += new ExecutedRoutedEventHandler(cbMapDataTool_Executed);
           cbMapDataTool.CanExecute += new CanExecuteRoutedEventHandler(cbMapDataTool_CanExecute);
           window.CommandBindings.Add(cbMapDataTool);

           CommandBinding cbView2d3d = new CommandBinding();
           cbView2d3d.Command = view2d3d;

           cbView2d3d.Executed += new ExecutedRoutedEventHandler(cbView2d3d_Executed);
           cbView2d3d.CanExecute += new CanExecuteRoutedEventHandler(cbView2d3d_CanExecute);

           window.CommandBindings.Add(cbView2d3d);



       }

       static void cbView2d3d_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;

       }

       static void cbView2d3d_Executed(object sender, ExecutedRoutedEventArgs e)
       {

           UIModule.DefaultModule.RendererViewModel.View2D = UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.View2D;

       }

       static void cbMapDataTool_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbMapDataTool_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.MAPDATA;
       }



       static void cbGrid3dTool_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbGrid3dTool_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.GRID3D;
       }

       static void cbScatter2dTool_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbScatter2dTool_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.SCATTER2D;
       }

       static void cbEditBootElevation_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditBootElevation_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           winCellCenterDSEdit win = new winCellCenterDSEdit(ProjectService.DefaultService.Project.MfData.GridData.GetBotElevationDs(), ProjectService.DefaultService.Project);
           win.Owner = mainWindow;
           win.ResizeMode = ResizeMode.NoResize;
           win.Unit += "(" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + ")";
           win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (win.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.GridData.SetBotElevationDS(win.PcDs.Dataset);
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == win.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.CurrentDSData = ProjectService.DefaultService.Project.MfData.GridData.GetBotElevationDs();
           }
       }

       static void cbEditTopElevation_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditTopElevation_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           winCellCenterDSEdit win = new winCellCenterDSEdit(ProjectService.DefaultService.Project.MfData.GridData.GetTopElevationDs(), ProjectService.DefaultService.Project);
           win.Owner = mainWindow;
           win.Unit += "(" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + ")";
           win.ResizeMode = ResizeMode.NoResize;
           win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (win.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.GridData.SetTopElevationDS(win.PcDs.Dataset);
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == win.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.CurrentDSData = ProjectService.DefaultService.Project.MfData.GridData.GetTopElevationDs();
           }
       }

       static void cbEditIbound_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           winCellCenterDSEdit win = new winCellCenterDSEdit(ProjectService.DefaultService.Project.MfData.GridData.GetIBoundDs(), ProjectService.DefaultService.Project);
           win.Owner = mainWindow;
           win.ResizeMode = ResizeMode.NoResize;
           win.Unit += "无量纲";
           win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (win.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.GridData.SetIBoundDs(win.PcDs.Dataset);
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == win.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.CurrentDSData = ProjectService.DefaultService.Project.MfData.GridData.GetIBoundDs();
           }
       }

       static void cbEditIbound_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditHead_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditHead_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           winCellCenterDSEdit win = new winCellCenterDSEdit(ProjectService.DefaultService.Project.MfData.GridData.GetIHeadDs(), ProjectService.DefaultService.Project);
           win.Owner = mainWindow;
           win.ResizeMode = ResizeMode.NoResize;
           win.Unit += "(" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + ")";
           win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (win.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.GridData.SetIHeadDs(win.PcDs.Dataset);
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == win.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.CurrentDSData = ProjectService.DefaultService.Project.MfData.GridData.GetIHeadDs();
           }
       }

       static void cbEditWetDry_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditWetDry_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsWetDry = ProjectService.DefaultService.Project.MfData.FlowData.WetDry;

           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsWetDry, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "无量纲";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.WetDry = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditLeakance_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsLeakance = ProjectService.DefaultService.Project.MfData.FlowData.BcfData.Leakance;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsLeakance, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "(1/" + Domain.DomainLayer.UnitConverter.GetTime(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Time) + ")";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.BcfData.Leakance = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditLeakance_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditSecondaryStorage_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsSecondaryStorage = ProjectService.DefaultService.Project.MfData.FlowData.BcfData.SecondaryStorage;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsSecondaryStorage, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "无量纲";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.BcfData.SecondaryStorage = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditSecondaryStorage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditPrimaryStorage_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsPrimaryStorage = ProjectService.DefaultService.Project.MfData.FlowData.BcfData.PrimaryStorage;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsPrimaryStorage, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "无量纲";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.BcfData.PrimaryStorage = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditPrimaryStorage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditTransmissivity_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsTransmissivity = ProjectService.DefaultService.Project.MfData.FlowData.BcfData.Transmissivity;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsTransmissivity, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "(" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Time) + ")";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.BcfData.Transmissivity = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditTransmissivity_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditVkcb_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsVkcb = ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Vkcb;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsVkcb, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "(" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + "/" + Domain.DomainLayer.UnitConverter.GetTime(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Time) + ")";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Vkcb = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditVkcb_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditVka_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsVka = ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Vka;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsVka, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "(" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + "/" + Domain.DomainLayer.UnitConverter.GetTime(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Time) + ")";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Vka = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditVka_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditSy_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsSy = ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Sy;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsSy, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "无量纲";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Sy = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditSy_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditSs_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditSs_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsSs = ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Ss;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsSs, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "(1/" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + ")";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Ss = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditHani_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbEditHani_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           CellCenterDataSet3d dsHani = ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Hani;
           winCellCenterDSEdit edit = new winCellCenterDSEdit(dsHani, ProjectService.DefaultService.Project);
           edit.Owner = mainWindow;
           edit.ResizeMode = ResizeMode.NoResize;
           edit.Unit += "无量纲";
           edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (edit.ShowDialog() == true)
           {
               ProjectService.DefaultService.Project.MfData.FlowData.LpfData.Hani = edit.PcDs.Dataset;
               if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                   ProjectService.DefaultService.Project.OnCurrentDSChanged();
           }
       }

       static void cbEditHk_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           

            CellCenterDataSet3d dsHk=   ProjectService.DefaultService.Project.MfData.FlowData.Hk;


            winCellCenterDSEdit edit = new winCellCenterDSEdit(dsHk, ProjectService.DefaultService.Project);
            edit.Owner = mainWindow;
            edit.ResizeMode = ResizeMode.NoResize;
            edit.Unit += "(" + Domain.DomainLayer.UnitConverter.GetLength(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Length) + "/" + Domain.DomainLayer.UnitConverter.GetTime(ProjectService.DefaultService.Project.MfData.ModelOption.Units.Time) + ")";
            edit.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            if (edit.ShowDialog()==true)
            {

                ProjectService.DefaultService.Project.MfData.FlowData.Hk = edit.PcDs.Dataset;
                if (ProjectService.DefaultService.Project.CurrentDSData != null && ProjectService.DefaultService.Project.CurrentDSData.Label == edit.PcDs.Dataset.Label)
                    ProjectService.DefaultService.Project.OnCurrentDSChanged();
            }



           
           
           
       }

       static void cbEditHk_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }



    }
}
